<template>
	<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="lowerBottom">
		<uni-list class="feedback-list" style="margin-bottom: 10px;">
			<uni-list-item direction="row" v-for="item in data" :key="item.id" clickable @click="showContent(item)">
				<template v-slot:body>
					<view class="uni-list-box uni-content">
						<view class="title uni-ellipsis-2">
							{{item.title}}<span v-if="item.status_text">【{{item.status_text}}】</span>
						</view>
						<view class="date">
							{{item.createtime}}
						</view>
					</view>
				</template>
			</uni-list-item>
		</uni-list>
		<uni-load-more v-if="showLoad" :status="loadStatus" />
		<image src="https://zhzx.on-line-demo.com/image/zwsj.png" mode="aspectFit" class="no-data"
			v-if="loadStatus == 'no-more' && data.length == 0"></image>
	</scroll-view>
</template>

<script>
	import Header from '../../components/header.vue'
	import request from '../../common/request.js'
	export default {
		components: {
			Header,
		},
		data() {
			return {
				data: [],
				page: 1,
				loadStatus: 'loading',
				showLoad: false,
			}
		},
		mounted() {
			this.getListData()
		},
		methods: {
			showContent(data) {
				if (data.status == 1) {
					data.page = 'list'
					uni.$emit('showContent', data)
				} else {
					uni.navigateTo({
						url: `/pages/resumption/speakDetail?id=${data.id}`
					})
				}
			},
			lowerBottom() {
				if (this.loadStatus != 'loading') {
					this.loadStatus = 'loading'
					this.showLoad = true
					this.page++
					this.getListData()
				}
			},
			getListData() {
				request({
					url: '/speak/dhfy',
					data: {
						page: this.page
					},
					method: 'POST',
				}).then(res => {
					if (res.code == 1) {
						this.data = this.data.concat(res.data)
						if (this.page == res.lastPage) {
							this.loadStatus = 'no-more'
						} else {
							this.loadStatus = 'more'
							this.showLoad = false
						}
					} else {
						this.loadStatus = 'no-more'
					}
				})
			},
		}
	}
</script>

<style scoped>
	::v-deep .uni-list {
		background-color: transparent !important;
	}

	::v-deep .uni-list-item {
		margin: 10px;
		border-radius: 12px;
	}

	.title span,
	.title label {
		color: #fb7a30;
	}
</style>